package sys.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sys.dao.PersonDao;
import sys.entity.PageResult;
import sys.entity.Person;
import sys.entity.QueryPageBean;
import sys.service.PersonService;



/**
 * @author 秉性哥
 * @createTime 2022/9/20 15:51
 * @description
 */
@Service
public class PersonServiceImpl implements PersonService {
    @Autowired
    private PersonDao personDao;

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Person> page=personDao.findPage();
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(Person person) {
        personDao.add(person);
    }

    @Override
    public void del(Integer id) {
        personDao.del(id);
    }

    @Override
    public void edit(Person person) {
        personDao.edit(person);
    }

    @Override
    public void dels(Integer[] ids) {
        for (Integer id : ids) {
            personDao.dels(id);
        }
    }
}
